﻿<UserControl x:Class="BusinessManager.UIControls.BOPManagerControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:Helper="clr-namespace:BusinessManager.Helps"
             mc:Ignorable="d" Loaded="UserControl_Loaded"
             d:DesignHeight="300" d:DesignWidth="1000">
    <UserControl.Resources>
        <Helper:OperationEnumToBoolConverter x:Key="operationEnumToBoolConverter"/>
        <Helper:OperationEnumToVisibilityConverter x:Key="operationEnumToVisibilityConverter"/>
        <Helper:OperationEnumToNoVisibilityConverter x:Key="operationEnumToNoVisibilityConverter"/>
        <Helper:BOPTypeEnumToBoolConverter x:Key="bopTypeEnumToBoolConverter"/>
        <Helper:BOPTypeEnumToGroupShowConverter x:Key="bopTypeEnumToGroupShowConverter"/>
        <Helper:IDToBoolConverter x:Key="idToBoolConverter"/> 
        
        <sys:Boolean x:Key="boolParam_true">true</sys:Boolean>
        <sys:Boolean x:Key="boolParam_false">false</sys:Boolean>

        <CollectionViewSource x:Key="ViewSource" Filter="CollectionViewSource_Filter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="30"/>
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto"/> 
                <ColumnDefinition Width="*"/>  
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" IsEnabled="{Binding SelectedValue.Key, ElementName=OperationTypeList,Converter={StaticResource operationEnumToBoolConverter},ConverterParameter={StaticResource boolParam_true}}">
                <Border BorderBrush="#FFC2C2C2" BorderThickness="1,1,1,0"  Width="140" Background="{StaticResource BgColor}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="25"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Path Grid.Column="0" Fill="{StaticResource FgColor}" Height="19" Width="18" Stretch="Fill" Data="M22.1575,13.53399L21.794301,25.304994C21.794301,25.304994,21.3242,33.088695,12.747401,32.148692L5.3958107,31.949492 5.3958107,65.390895C5.3958107,66.135493,6.0026208,66.7391,6.7473808,66.7391L44.5313,66.7391C45.2734,66.7391,45.8802,66.135493,45.8802,65.390895L45.8802,14.883091C45.8802,14.140891,45.2734,13.53399,44.5313,13.53399z M21.804701,8.1369996L44.5313,8.1369996C48.257802,8.1370001,51.279999,11.15899,51.279999,14.883091L51.279999,65.390895C51.279999,69.117496,48.257802,72.136996,44.5313,72.136996L6.7473808,72.136996C3.0208105,72.136996,5.8073994E-07,69.117496,0,65.390895L0,31.142392 2.6718808,28.322993 2.6745006,28.246392 16.6771,13.53399 16.638001,13.53399 12.8945,17.483192 16.816401,13.328391 16.872401,13.328391 16.9961,13.19799 17.0078,13.19799z M30.352,0L55.255002,0 60.581002,0 60.581002,4.747 60.581002,55.207999 55.255002,55.207999 55.255002,4.747 30.352,4.747z"/>
                        <TextBlock Text="类型" Foreground="{StaticResource FgColor}" Grid.Column="1" Margin="1,0,5,0" VerticalAlignment="Center" FontSize="14"/>
                        <ComboBox x:Name="BOPTypeList" Grid.Column="2" ItemsSource="{x:Static Helper:ResourceMap.BOPTypeHasntable}" DisplayMemberPath="Value"  FontSize="14" BorderBrush="{x:Null}" IsEditable="False" SelectionChanged="BOPTypeList_SelectionChanged" IsSynchronizedWithCurrentItem="false" SelectedIndex="0"/>
                    </Grid>
                </Border>
                <Border BorderBrush="#FFC2C2C2" BorderThickness="0,1,1,0" Width="200" Background="{StaticResource BgColor}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="25"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Path Grid.Column="0" Fill="{StaticResource FgColor}" Height="15" Width="15" Stretch="Fill" Data="M45.000001,15 C28.431458,15 15.000001,28.431458 15.000001,45 15.000001,61.568542 28.431458,75 45.000001,75 61.568543,75 75.000001,61.568542 75.000001,45 75.000001,28.431458 61.568543,15 45.000001,15 z M45.000001,0 C69.852814,0 90.000001,20.147186 90.000001,45 90.000001,54.70813 86.925782,63.698238 81.697739,71.049934 L81.199387,71.733231 104.35693,94.89077 C107.18823,97.722069 107.18823,102.31252 104.35693,105.14381 L103.64982,105.85092 C100.81851,108.68222 96.228066,108.68222 93.396767,105.85092 L69.979386,82.43354 69.25454,82.910645 C62.255227,87.39798 53.931481,90 45.000001,90 20.147187,90 5.8843307E-07,69.852814 0,45 5.8843307E-07,20.147186 20.147187,0 45.000001,0 z"/>
                        <TextBlock Text="事由" Foreground="{StaticResource FgColor}" Grid.Column="1" Margin="0,0,5,0" VerticalAlignment="Center" FontSize="14"/>
                        <TextBox x:Name="FitterGeneralText" Height="28" Grid.Column="2" BorderBrush="{x:Null}" FontSize="14" TextChanged="TextBox_TextChanged"/>
                    </Grid>
                </Border>
                <Border BorderBrush="#FFC2C2C2" BorderThickness="0,1,1,0" Width="330" Background="{StaticResource BgColor}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="25"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="5"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="5"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Path Grid.Column="0" Fill="{StaticResource FgColor}" Height="17" Width="18" Stretch="Fill" Data="F1 M 26.0801,46.4635L 29.7106,46.0201C 29.8132,46.9475 30.0908,47.6566 30.5432,48.1473C 30.9957,48.6381 31.5434,48.8835 32.1863,48.8835C 32.8751,48.8835 33.4558,48.6178 33.9286,48.0863C 34.4013,47.5549 34.6376,46.8377 34.6376,45.9347C 34.6376,45.0806 34.4256,44.404 34.0015,43.9051C 33.5774,43.4062 33.0601,43.1567 32.4496,43.1567C 32.0472,43.1567 31.5663,43.2448 31.0072,43.4211L 31.3394,40.2933C 32.1579,40.3177 32.7826,40.1218 33.2134,39.7056C 33.6443,39.2893 33.8597,38.7382 33.8597,38.0522C 33.8597,37.4665 33.6949,36.9994 33.3653,36.651C 33.0358,36.3025 32.5969,36.1283 32.0485,36.1283C 31.511,36.1283 31.0511,36.3276 30.6689,36.7262C 30.2866,37.1248 30.0536,37.7065 29.9699,38.4711L 26.3395,37.9464C 26.5664,36.8022 26.9081,35.8884 27.3646,35.205C 27.8211,34.5217 28.4579,33.9842 29.275,33.5923C 30.0921,33.2005 31.0072,33.0046 32.0201,33.0046C 33.757,33.0046 35.1482,33.5632 36.1935,34.6804C 37.0579,35.5969 37.4901,36.6313 37.4901,37.7837C 37.4901,39.4188 36.5852,40.7231 34.7754,41.6965C 35.8343,41.9243 36.6811,42.4354 37.3159,43.2299C 37.9507,44.0244 38.2681,44.9843 38.2681,46.1096C 38.2681,47.742 37.6799,49.133 36.5035,50.2827C 35.3271,51.4324 33.8637,52.0073 32.1133,52.0073C 30.4521,52.0073 29.0751,51.4961 27.9825,50.4739C 26.8898,49.4516 26.2557,48.1148 26.0801,46.4635 Z M 48.0047,52.0073L 45.0042,52.0073L 45.0042,38.5053C 43.6649,39.8964 42.157,40.7849 40.3412,41.4502L 40.3412,37.7553C 41.2997,37.4474 42.3405,36.8645 43.4633,36.0068C 44.5862,35.149 45.3572,34.1483 45.7762,33.0046L 48.0047,33.0046L 48.0047,52.0073 Z M 18.0025,57.0082L 18.0025,23.0033L 23.0032,23.0033L 23.0032,20.0029C 23.0033,18.898 23.8988,18.0026 25.0035,18.0026L 29.004,18.0026C 30.1087,18.0026 31.0042,18.898 31.0043,20.0026L 31.0043,23.0033L 45.0063,23.0033L 45.0062,20.0026C 45.0062,18.8979 45.9018,18.0023 47.0065,18.0023L 51.0071,18.0023C 52.1118,18.0023 53.0073,18.8979 53.0073,20.0026L 53.0074,23.0033L 58.0081,23.0033L 58.0081,57.0082L 18.0025,57.0082 Z M 21.0029,54.0078L 55.0076,54.0078L 55.0076,31.0044L 21.0029,31.0044L 21.0029,54.0078 Z M 48.5067,20.0029C 47.6781,20.0029 47.0065,20.6746 47.0065,21.5031L 47.0065,24.5036C 47.0065,25.3321 47.6781,26.0038 48.5067,26.0038L 49.5068,26.0038C 50.3354,26.0038 51.007,25.3321 51.007,24.5036L 51.007,21.5031C 51.007,20.6746 50.3354,20.0029 49.5068,20.0029L 48.5067,20.0029 Z M 26.5037,20.0029C 25.6751,20.0029 25.0035,20.6746 25.0035,21.5031L 25.0035,24.5035C 25.0035,25.3321 25.6751,26.0037 26.5037,26.0037L 27.5038,26.0037C 28.3324,26.0037 29.004,25.3321 29.004,24.5035L 29.004,21.5031C 29.004,20.6746 28.3324,20.0029 27.5038,20.0029L 26.5037,20.0029 Z"/>
                        <TextBlock Text="日期" Foreground="{StaticResource FgColor}" Grid.Column="1" Margin="1,0,5,0" VerticalAlignment="Center" FontSize="14"/>
                        <DatePicker x:Name="StartDatePicker" Grid.Column="2" BorderThickness="0" VerticalContentAlignment="Stretch" SelectedDateChanged="RangeDatePicker_SelectedDateChanged" Foreground="{StaticResource FgColor}" FontSize="14"/>
                        <TextBlock Grid.Column="4" Text="-" VerticalAlignment="Center"/>
                        <DatePicker x:Name="EndDatePicker"  Grid.Column="6" BorderThickness="0" VerticalContentAlignment="Stretch" SelectedDateChanged="RangeDatePicker_SelectedDateChanged" Foreground="{StaticResource FgColor}" FontSize="14"/>
                    </Grid>
                </Border>
            </StackPanel>
            <ListBox x:Name="OperationTypeList" Grid.Column="2" ItemContainerStyle="{StaticResource OperationItem}" ItemsPanel="{StaticResource OperationItemsPanelTemplate}" SelectedIndex="0"
                     ItemsSource="{x:Static Helper:ResourceMap.GeneralOperationTypeHasntable}" DisplayMemberPath="Value" BorderThickness="0" SelectionChanged="OperationTypeList_SelectionChanged"/>
        </Grid> 
        <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
            <StackPanel VerticalAlignment="Top">
                <DataGrid x:Name="BOPDataGrid" ItemsSource="{Binding Source={StaticResource ViewSource}}"
                  AutoGenerateColumns="False" CanUserSortColumns="True" CanUserAddRows="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                  IsReadOnly="{Binding SelectedValue.Key, ElementName=OperationTypeList,Converter={StaticResource operationEnumToBoolConverter},ConverterParameter={StaticResource boolParam_true}}"
                  CanUserReorderColumns="False">
                    <!--
                    <DataGrid.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TextBlock Margin="0,5" Text="{Binding Path=Name,Converter={StaticResource bopTypeEnumToGroupShowConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" FontWeight="Bold" Foreground="Black"/>
                                    </StackPanel>
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                            <GroupStyle.ContainerStyle>
                                <Style TargetType="{x:Type GroupItem}">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type GroupItem}">
                                                 <ItemsPresenter />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </GroupStyle.ContainerStyle>
                        </GroupStyle>
                    </DataGrid.GroupStyle>-->
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Header="日期" Width="90" CanUserSort="True" SortMemberPath="BOPDate">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <TextBlock Text="{Binding BOPDate,StringFormat={}{0:yyyy-MM-dd}}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"  ToolTip="{Binding Text,RelativeSource={RelativeSource Self}}"/>
                                    </Grid>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <DatePicker SelectedDate="{Binding Path=BOPDate, Mode=TwoWay}" BorderThickness="0" VerticalContentAlignment="Stretch" FontSize="13"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="事由或品名" Width="*" CanUserSort="True" SortMemberPath="BOPReson">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding BOPReason}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text,RelativeSource={RelativeSource Self}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding BOPReason,Mode=TwoWay}" BorderBrush="{x:Null}" BorderThickness="0"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn x:Name="balanceColumn" Header="收入(元)" Width="70" CanUserSort="True" SortMemberPath="Balance">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Balance}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text,RelativeSource={RelativeSource Self}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Balance,Mode=TwoWay}" BorderBrush="{x:Null}" BorderThickness="0"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn x:Name="paymentColumn" Header="支出(元)" Width="70" CanUserSort="True" SortMemberPath="Payment" IsReadOnly="{Binding BOP_Type,Converter={StaticResource bopTypeEnumToBoolConverter},ConverterParameter=false}">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Payment}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text,RelativeSource={RelativeSource Self}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Payment,Mode=TwoWay}" BorderBrush="{x:Null}" BorderThickness="0"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn x:Name="departmentColumn" Header="部门" Width="90" CanUserSort="True" SortMemberPath="DepartmentName">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding DepartmentName}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text,RelativeSource={RelativeSource Self}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <ComboBox SelectedValue="{Binding DepartmentID,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="13" BorderBrush="{x:Null}" ItemsSource="{Binding SelectionDepartmentInfoList}" DisplayMemberPath="DepartmentName" SelectedValuePath="ID" IsEditable="False" 
                                              IsEnabled="{Binding BOP_Type,Converter={StaticResource bopTypeEnumToBoolConverter},ConverterParameter={StaticResource boolParam_true}}">
                                    </ComboBox>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="会计主管" Width="80">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding AccountingSupervisorName}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding AccountingSupervisorID,Converter={StaticResource stringFormatForIDConverter}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <ComboBox SelectedValue="{Binding AccountingSupervisorID,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="13" ToolTip="{Binding SelectedValue,Converter={StaticResource stringFormatForIDConverter},RelativeSource={RelativeSource Self}}" BorderBrush="{x:Null}" ItemsSource="{Binding SelectionEmployeeInfoList}" DisplayMemberPath="EmployeeName" ItemContainerStyle="{StaticResource EmployeeComboBoxItem}" SelectedValuePath="ID" IsEditable="False">
                                    </ComboBox>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="出纳" Width="80">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding CashierName}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding CashierID,Converter={StaticResource stringFormatForIDConverter}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <ComboBox SelectedValue="{Binding CashierID,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="13" ToolTip="{Binding SelectedValue,Converter={StaticResource stringFormatForIDConverter},RelativeSource={RelativeSource Self}}" BorderBrush="{x:Null}" ItemsSource="{Binding SelectionEmployeeInfoList}" DisplayMemberPath="EmployeeName" ItemContainerStyle="{StaticResource EmployeeComboBoxItem}" SelectedValuePath="ID" IsEditable="False">
                                    </ComboBox>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="经手人" Width="80" >
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding HandlerName}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding HandlerID,Converter={StaticResource stringFormatForIDConverter}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <ComboBox SelectedValue="{Binding HandlerID,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="13" ToolTip="{Binding SelectedValue,Converter={StaticResource stringFormatForIDConverter},RelativeSource={RelativeSource Self}}" BorderBrush="{x:Null}" ItemsSource="{Binding SelectionEmployeeInfoList}" DisplayMemberPath="EmployeeName" ItemContainerStyle="{StaticResource EmployeeComboBoxItem}" SelectedValuePath="ID" IsEditable="False">
                                    </ComboBox>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn x:Name="payeeColumn" Header="领款人" Width="80">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding PayeeName}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding PayeeID,Converter={StaticResource stringFormatForIDConverter}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <ComboBox SelectedValue="{Binding PayeeID,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="13" ToolTip="{Binding SelectedValue,Converter={StaticResource stringFormatForIDConverter},RelativeSource={RelativeSource Self}}" BorderBrush="{x:Null}" ItemsSource="{Binding SelectionEmployeeInfoList}" DisplayMemberPath="EmployeeName" ItemContainerStyle="{StaticResource EmployeeComboBoxItem}" SelectedValuePath="ID" IsEditable="False"
                                              IsEnabled="{Binding BOP_Type,Converter={StaticResource bopTypeEnumToBoolConverter},ConverterParameter={StaticResource boolParam_true}}">
                                    </ComboBox>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn x:Name="bkColumn" Header="记账" Width="80" >
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding BookKeepingName}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding BookKeepingID,Converter={StaticResource stringFormatForIDConverter}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <ComboBox SelectedValue="{Binding BookKeepingID,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="13" ToolTip="{Binding SelectedValue,Converter={StaticResource stringFormatForIDConverter},RelativeSource={RelativeSource Self}}" BorderBrush="{x:Null}" ItemsSource="{Binding SelectionEmployeeInfoList}" DisplayMemberPath="EmployeeName" ItemContainerStyle="{StaticResource EmployeeComboBoxItem}" SelectedValuePath="ID" IsEditable="False"
                                              IsEnabled="{Binding BOP_Type,Converter={StaticResource bopTypeEnumToBoolConverter},ConverterParameter={StaticResource boolParam_false}}">
                                    </ComboBox>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="备注" Width="150">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Remark}" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text,RelativeSource={RelativeSource Self}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Remark,Mode=TwoWay}" BorderBrush="{x:Null}" BorderThickness="0"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>
                <Grid Height="30" Margin="0.6" Visibility="{Binding SelectedValue.Key,ElementName=OperationTypeList,Converter={StaticResource operationEnumToNoVisibilityConverter}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0.6"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Button x:Name="AddBtn"  Style="{StaticResource BtnStyle}" Cursor="Hand"  ToolTip="添加" Click="AddBtn_Click">
                        <Button.Background>
                            <VisualBrush>
                                <VisualBrush.Visual>
                                    <Rectangle StrokeDashArray="1,2" Stroke="Black" StrokeThickness="1"
                                           Height="{Binding ActualHeight,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
                                           Width="{Binding ActualWidth,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"/>
                                </VisualBrush.Visual>
                            </VisualBrush>
                        </Button.Background>
                        <Path Width="20" Height="20" Stretch="Fill" Fill="{Binding Foreground,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Data="M35.355338,0 L35.355378,24.748676 60.103941,24.748827 60.103958,35.355434 35.355394,35.355284 35.355322,60.104071 24.748827,60.104166 24.748787,35.355267 0,35.355339 9.3460083E-05,24.74862 24.748882,24.748771 24.748842,9.5367432E-05 z"/>
                    </Button>
                    <Button x:Name="DeleteNewBtn" Grid.Column="2"  Style="{StaticResource DeleteStyle}" Cursor="Hand"  ToolTip="删除未保存项" Click="DeleteNewBtn_Click" IsEnabled="{Binding SelectedValue.ID,ElementName=BOPDataGrid, Converter={StaticResource idToBoolConverter}}">
                        <Button.Background>
                            <VisualBrush>
                                <VisualBrush.Visual>
                                    <Rectangle StrokeDashArray="1,2" Stroke="Black" StrokeThickness="1"
                                           Height="{Binding ActualHeight,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
                                           Width="{Binding ActualWidth,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"/>
                                </VisualBrush.Visual>
                            </VisualBrush>
                        </Button.Background>
                        <Path Width="20" Height="20" Stretch="Fill" Fill="{Binding Foreground,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Data="F1 M17,2.0910716 C24.761499,1.2201797 53.795077,26.462324 57.261926,30 61.283137,27.144705 87.524799,6.0009238 112.48433,3 112.94794,3.1928839 113.12278,3.5303927 113.12278,3.8633927 113.07072,4.3995821 112.48139,4.7638684 112.04911,4.9089284 98.077111,11.283928 86.618,20.243 75,29 71.664,31.514 65.279679,38.545569 65.279679,38.878569 65.612679,38.878569 95.356775,69.412714 95.901775,95.635714 95.663345,95.995171 95.24589,96.109011&#xa;94.884022,95.795089 91.214022,83.843089 67.00031,53.283414 57.455524,47.573214 53.576906,51.826271 35.237316,70.451836 30,83 26.267611,91.942487 31.768193,103.09817 16,103.54464 13.400179,103.28031 10.649888,101.91554 8.4284052,98.366086 5.0624052,94.077086 7.1375169,83.768719 10,78 18.310982,61.251006 46.178622,38.482997 46.178622,38.149997 42.671132,34.613168 24.602102,24.504843 14,20 8.203523,17.537072&#xa;0.43942972,13.9102 2.3942817,9.8785714 3.8424574,6.2602 12.977121,2.3732431 17,2.0910716 z"/>
                    </Button>
                </Grid>
            </StackPanel>
        </ScrollViewer>
        <Grid Grid.Row="2" Height="30">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="0.6"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="SaveBtn" Grid.Column="0"  BorderThickness="0.6" Style="{StaticResource BtnStyle}" Cursor="Hand"  ToolTip="保存" Visibility="{Binding SelectedValue.Key,ElementName=OperationTypeList,Converter={StaticResource operationEnumToNoVisibilityConverter}}" Click="SaveBtn_Click">
                <Path Width="20" Height="20" Stretch="Fill" Fill="{Binding Foreground,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Data="F1 M 20.5833,20.5833L 55.4167,20.5833L 55.4167,55.4167L 45.9167,55.4167L 45.9167,44.3333L 30.0833,44.3333L 30.0833,55.4167L 20.5833,55.4167L 20.5833,20.5833 Z M 33.25,55.4167L 33.25,50.6667L 39.5833,50.6667L 39.5833,55.4167L 33.25,55.4167 Z M 26.9167,23.75L 26.9167,33.25L 49.0833,33.25L 49.0833,23.75L 26.9167,23.75 Z"/>
            </Button>
            <Button x:Name="RestoreBtn" Grid.Column="2"  BorderThickness="0.6" Style="{StaticResource BtnStyle}" Cursor="Hand"  ToolTip="还原" Visibility="{Binding SelectedValue.Key,ElementName=OperationTypeList,Converter={StaticResource operationEnumToNoVisibilityConverter}}" Click="RestoreBtn_Click">
                <Path Width="20" Height="20" Stretch="Fill" Fill="{Binding Foreground,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Data="F1 M 19,57L 34,57L 34,42L 28.8076,47.1924C 26.4551,44.8399 25,41.5899 25,38C 25,30.8203 30.8203,25 38,25C 45.1797,25 51,30.8203 51,38C 51,42.6137 48.5965,46.6661 44.9734,48.9734L 49.2862,53.2862C 53.9658,49.8254 57,44.2671 57,38C 57,27.5066 48.4934,19 38,19C 27.5066,19 19,27.5066 19,38C 19,43.2467 21.1266,47.9967 24.565,51.435L 19,57 Z"/>
            </Button>
            <Button x:Name="DeleteBtn" Grid.Column="0"  BorderThickness="0.6" Style="{StaticResource BtnStyle}" Cursor="Hand"  ToolTip="删除" Visibility="{Binding SelectedValue.Key,ElementName=OperationTypeList,Converter={StaticResource operationEnumToVisibilityConverter}}" Click="DeleteBtn_Click">
                <Path Width="17" Height="20" Stretch="Fill" Fill="{Binding Foreground,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Data="F1 M 43,30L 50.75,30L 43,22.25L 43,30 Z M 52,34L 39,34L 39,21L 24,21L 24,39L 20,43L 20,17L 43.25,17L 56,29.75L 56,59L 36.5,59L 40.5,55L 52,55L 52,34 Z M 35.1379,40.67L 38.4967,44.0287L 32.8988,49.6266L 38.4967,55.2246L 35.1379,58.5833L 29.54,52.9854L 23.9421,58.5833L 20.5833,55.2246L 26.1813,49.6266L 20.5833,44.0287L 23.9421,40.67L 29.54,46.2679L 35.1379,40.67 Z"/>
            </Button>
            <Button x:Name="PrintBtn" Grid.Column="2" BorderThickness="0.6" Style="{StaticResource BtnStyle}" Cursor="Hand"  ToolTip="打印" Visibility="{Binding SelectedValue.Key,ElementName=OperationTypeList,Converter={StaticResource operationEnumToVisibilityConverter}}" Click="PrintBtn_Click">
                <Path Width="20" Height="20" Stretch="Fill" Fill="{Binding Foreground,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Data="F1 M 25,27L 25,17L 51,17L 51,27L 47,27L 47,21L 29,21L 29,27L 25,27 Z M 16,28L 60,28L 60,51L 52,51L 52,46L 55,46L 55,33L 21,33L 21,46L 24,46L 24,51L 16,51L 16,28 Z M 25,39L 28,39L 28,52L 35,52L 35,59L 48,59L 48,39L 51,39L 51,62L 33,62L 25,54L 25,39 Z M 46,55L 38,55L 38,52L 46,52L 46,55 Z M 46,49L 30,49L 30,46L 46,46L 46,49 Z M 46,43L 30,43L 30,40L 46,40L 46,43 Z"/>
            </Button>
        </Grid>
        <Grid x:Name="PageManagerGrid" Grid.Column="0" Grid.Row="3" Background="{StaticResource BgColor}" IsEnabled="{Binding SelectedValue.Key, ElementName=OperationTypeList,Converter={StaticResource operationEnumToBoolConverter},ConverterParameter={StaticResource boolParam_true}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="5"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="30"/>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="30"/>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="30"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="5"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" Grid.Column="1">
                <TextBlock Text="显示项结余总额: " VerticalAlignment="Center" FontSize="14" Foreground="{DynamicResource FgColor}"> 
                    <Run x:Name="CurTotalTextBlock" Text="2020"/><Run Text=" 元"/> 
                </TextBlock>
                <Button x:Name="FlushCurPrice" Margin="8,0,0,0" Style="{StaticResource IconBtnStyle}" Cursor="Hand"  ToolTip="刷新" Click="FlushCurPrice_Click">
                    <Path Width="20" Height="20" Stretch="Fill" Fill="{Binding Foreground,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Data="M35.028999,3.9430006 C17.892157,3.9430001 4.0000005,17.834932 3.9999998,34.9715 4.0000005,52.108067 17.892157,66 35.028999,66 52.165844,66 66.057999,52.108067 66.057999,34.9715 66.057999,17.834932 52.165844,3.9430001 35.028999,3.9430006 z M35,0 C54.329967,0 70,15.670034 70,35 70,54.329967 54.329967,70 35,70 15.670034,70 0,54.329967 0,35 0,15.670034 15.670034,0 35,0 z M55.007,15 L55.006542,33.589442 37.572159,33.589655 44.665507,25.931355 44.309516,25.565982 C42.377645,23.582183 40.704987,21.965671 35.348769,21.913803 28.015815,21.842792 22.917756,26.375502 22.056772,32.387369 L16.186065,30.229433 C17.678303,21.141225 25.197462,15.661925 35.457043,15.661925 40.670929,15.661925 45.406642,17.754109 48.904135,21.161768 L48.997213,21.254645 z M15.159879,55 L15.007,36.411215 32.44145,36.260798 25.411245,43.979938 25.770251,44.342231 C27.718493,46.309316 29.404491,47.91136 34.761158,47.917081 42.094727,47.924913 46.587578,42.884483 48.118273,36.83288 L53.823846,39.269408 C51.459928,47.863855 44.964075,54.081279 34.704453,54.169669 29.490546,54.214588 24.737557,52.163278 21.211942,48.785873 L21.118097,48.693801 z"/>
                </Button>
            </StackPanel>

            <StackPanel Orientation="Horizontal" Grid.Column="3">
                <TextBlock Text="每页 " Foreground="{DynamicResource FgColor}" VerticalAlignment="Center" FontSize="14"/>
                <TextBox Text="{Binding CountPerPage,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" Height="25" Width="40" HorizontalContentAlignment="Center" Margin="0,0,4,0" IsEnabled="{Binding IsCountPerPageEnabled}"/>
                <TextBlock Text="{Binding TotalCount,StringFormat=条\,共 {0} 条}" Foreground="{DynamicResource FgColor}" VerticalAlignment="Center" FontSize="14"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Grid.Column="5">
                <TextBlock Text="当前第 " Foreground="{DynamicResource FgColor}" VerticalAlignment="Center" FontSize="14"/>
                <TextBox Text="{Binding CurrentPage,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" Height="25" Width="40" HorizontalContentAlignment="Center" Margin="0,0,4,0" IsEnabled="{Binding IsJumpPageEnabled}"/>
                <TextBlock Text="{Binding TotalPages,StringFormat=页\,共 {0} 页}" Foreground="{DynamicResource FgColor}" VerticalAlignment="Center" FontSize="14"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Grid.Column="7" HorizontalAlignment="Right">
                <Button Style="{StaticResource IconBtnStyle}" Content="首页" Cursor="Hand" FontSize="15" IsEnabled="{Binding IsFirstEnabled}" Click="FirstPageBtn_Click"/>
                <Button Style="{StaticResource IconBtnStyle}" Content="上一页" Cursor="Hand" Margin="30,0" FontSize="15" IsEnabled="{Binding IsPreEnabled}" Click="PrePageBtn_Click"/>
                <Button Style="{StaticResource IconBtnStyle}" Content="下一页" Cursor="Hand" FontSize="15" IsEnabled="{Binding IsNextEnabled}" Click="NextPageBtn_Click"/>
                <Button Style="{StaticResource IconBtnStyle}" Content="末页" Cursor="Hand" Margin="30,0,0,0" FontSize="15" IsEnabled="{Binding IsLastEnabled}" Click="LastPageBtn_Click"/>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
